package cn.ichiva.dl.tushare.tu.data;


import cn.ichiva.tushare.sdk.tushare.TuConfig;
import cn.ichiva.tushare.sdk.tushare.TuDataCacheAble;
import cn.ichiva.tushare.sdk.tushare.entity.TuRequest;

import java.util.HashMap;
import java.util.LinkedHashMap;

import static cn.ichiva.dl.tushare.tu.Config.tuConfig;

/**
 * 股票列表
 *
 * 获取2000年到现在的所有数据
 */
public class StockBasic extends TuDataCacheAble {

    public StockBasic(TuConfig config) {
        super(config);

        TuRequest request = new TuRequest();
        request.setApi("stock_basic");
        request.setDescribe("获取基础信息数据，包括股票代码、名称、上市日期、退市日期等");

        HashMap<String,String> paramsMap = new HashMap<>();
        request.setParams(paramsMap);

        LinkedHashMap<String,String> fieldMap = new LinkedHashMap<>();
        fieldMap.put("ts_code","TS代码");
        fieldMap.put("symbol","股票代码");
        fieldMap.put("name","股票名称");
        fieldMap.put("area","所在地域");
        fieldMap.put("industry","所属行业");
        fieldMap.put("fullname","股票全称");
        fieldMap.put("enname","英文全称");
        fieldMap.put("market","市场类型 （主板/中小板/创业板/科创板）");
        fieldMap.put("exchange","交易所代码");
        fieldMap.put("curr_type","交易货币");

        request.setFieldMap(fieldMap);
        setRequest(request);
    }

    public static void main(String[] args) {
        new StockBasic(tuConfig).get().ifPresent(System.out::println);
    }
}
